package com.rc.saas.mini.service.hlht;

import com.rc.saas.mini.mapper.hlht.HlhtTenantOpenMapper;
import com.rc.saas.mini.model.hlht.HlhtTenantOpen;
import com.rc.saas.mini.model.hlht.HlhtTenantOpenExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wangzhengwei
 * @create 2021/12/18
 */
@Service
public class HlhtTenantOpenServiceImpl implements HlhtTenantOpenService {

    @Autowired
    private HlhtTenantOpenMapper hlhtTenantOpenMapper;

    @Override
    public HlhtTenantOpenMapper getMapper() {
        return hlhtTenantOpenMapper;
    }

    @Override
    public List<HlhtTenantOpen> listHlhtTenantOpenBySaas(String hlhtTenantCode, String hlhtType) {
        HlhtTenantOpenExample example = new HlhtTenantOpenExample();
        example.createCriteria().andStatusEqualTo("1").andHlhtTypeEqualTo(hlhtType).andHlhtTenantCodeEqualTo(hlhtTenantCode);
        return hlhtTenantOpenMapper.selectByExample(example);
    }

    @Override
    public HlhtTenantOpen selectHlhtTenantOpenBySaas(String hlhtTenantCode, String tenantCode, String hlhtType) {
        HlhtTenantOpenExample example = new HlhtTenantOpenExample();
        example.createCriteria().andStatusEqualTo("1").andHlhtTypeEqualTo(hlhtType).andTenantCodeEqualTo(tenantCode).andHlhtTenantCodeEqualTo(hlhtTenantCode);
        return hlhtTenantOpenMapper.selectByExample(example).stream().findFirst().orElseGet(() -> null);
    }

    @Override
    public List<HlhtTenantOpen> listHlhtTenantOpenByHlhtOpenType(String tenantCode, String hlhtType, String hlhtOpenType) {
        HlhtTenantOpenExample example = new HlhtTenantOpenExample();
        example.createCriteria().andStatusEqualTo("1").andHlhtTypeEqualTo(hlhtType).andHlhtOpenTypeEqualTo(hlhtOpenType).andHlhtTenantCodeEqualTo(tenantCode);
        return hlhtTenantOpenMapper.selectByExample(example);
    }
}
